package com.fr.data.impl;

import com.fr.base.FRContext;
import com.fr.base.core.ComparatorUtils;
import com.fr.base.core.list.IntList;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.data.AbstractTableData;
import com.fr.data.TableData;
import com.fr.data.TableDataException;
import com.fr.data.core.DataXMLUtils;
import java.util.logging.Level;
import java.util.logging.Logger;

public class RowsTableData extends AbstractTableData
{
  private TableData tableData;
  private int[] rows;

  public RowsTableData(TableData paramTableData, int[] paramArrayOfInt)
  {
    this.tableData = paramTableData;
    if (paramArrayOfInt == null)
      paramArrayOfInt = new int[0];
    this.rows = paramArrayOfInt;
  }

  public int getColumnCount()
    throws TableDataException
  {
    return this.tableData.getColumnCount();
  }

  public String getColumnName(int paramInt)
    throws TableDataException
  {
    return this.tableData.getColumnName(paramInt);
  }

  public int getRowCount()
  {
    return this.rows.length;
  }

  public Object getValueAt(int paramInt1, int paramInt2)
    throws TableDataException
  {
    return this.tableData.getValueAt(this.rows[paramInt1], paramInt2);
  }

  public TableData getTableData()
  {
    return this.tableData;
  }

  public int[] getRows()
  {
    return this.rows;
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    super.readXML(paramXMLableReader);
    if ((paramXMLableReader.isChildNode()) && (paramXMLableReader.getTagName().equals("TableData")))
    {
      EmbeddedTableData localEmbeddedTableData = (EmbeddedTableData)DataXMLUtils.readXMLTableData(paramXMLableReader);
      if (localEmbeddedTableData != null)
        this.rows = IntList.range(localEmbeddedTableData.getRowCount());
      this.tableData = localEmbeddedTableData;
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    super.writeXML(paramXMLPrintWriter);
    if (this.tableData != null)
      try
      {
        DataXMLUtils.writeXMLTableData(paramXMLPrintWriter, EmbeddedTableData.embedify(this));
      }
      catch (Exception localException)
      {
        FRContext.getLogger().log(Level.WARNING, "embedify failed...", localException);
      }
  }

  public boolean equals(Object paramObject)
  {
    return ((paramObject instanceof RowsTableData) && (super.equals(paramObject)) && (ComparatorUtils.equals(this.rows, ((RowsTableData)paramObject).rows)) && (ComparatorUtils.equals(this.tableData, ((RowsTableData)paramObject).tableData)));
  }
}